#ifndef CORE_H
#define CORE_H

#ifdef __CUDACC__
#define trace(type,method,...) cuPrintf(#type":"method"\n",__VA_ARGS__)
#define thrownew(type,...) { cuPrintf("\n\nTHROWS:\n"#type"\n"); __THROW; }
#else
#include <stdio.h>
# define __device__
# define trace(type,method,...) printf(#type":"method"\n",__VA_ARGS__)
# define thrownew(type,...) { printf("\n\nTHROWS:\n"#type); char c; scanf_s("%c", &c); throw; }
#endif

//typedef enum {false, true} bool;
typedef unsigned char byte;
//typedef char^std^
typedef long int decimal;
//typedef double^std^
//enum^std^
//typedef float^std^
typedef long int int_;
typedef long long int long_;
typedef signed char sbyte;
typedef short int short_;
//struct^std^
typedef unsigned long int uint;
typedef unsigned long long int ulong;
typedef unsigned short int ushort;

typedef char* string;
#define Debug_Assert

//# array functions
#define array_getLength(t) *((size_t*)t-1)
#define array_getSize(T,length) ((sizeof(T)*length)+sizeof(size_t))
#define array_getSizeEx(res,length) (((res)*length)+sizeof(size_t))
#define newArray(t,T,length) (T*)((size_t*)malloc(sizeof(T)*length+4)+1);*((size_t*)t-1)=length
#define freeArray(t) free((size_t*)t-1)

#ifdef __CUDACC__
# define cuNewArray(t,T,length) (T*)((size_t*)falloc(sizeof(T)*length+4)+1);*((size_t*)t-1)=length
#endif

#endif // CORE_H